home *** CD-ROM | disk | FTP | other *** search
- {A program to test a BIN program in an enviornment that TD can handle}
- {RunBin Copyright 1989 Michael Day V1.01 as of 15 April 1989}
- {all rights reserved}
-
- {$F+,R-}
- Program RunBin;
-
- type TestArray = array[0..65500] of byte;
- TestPtr = ^TestArray;
-
- var TestData : pointer;
- TestPrg : TestPtr;
- WorkString : string;
- StrPtr : pointer;
- Fil : string;
- f : file;
- j,size,result : word;
- s : string;
-
- begin
- GetMem(TestData,sizeof(TestArray)+16); {grab some working space}
- TestPrg := ptr(seg(TestData^)+1,0); {force addr to segment boundry}
- StrPtr := @WorkString[1]; {point to the working string}
-
- if ParamCount > 0 then fil := ParamStr(1) {get the program name}
- else
- begin {didn't give one, so}
- write('Enter name of BIN program to test: '); {try asking for it}
- readln(fil);
- end;
- j := 0;
- repeat inc(j) until (j > length(fil)) or (fil[j] = '.'); {if no ext}
- if j > length(fil) then fil := fil+'.BIN'; {add one}
-
- writeln('Testing: ',fil); {tell 'em what we are using}
- writeln;
- assign(f,fil);
- reset(f,1);
- size := filesize(f); {check if we can load it}
- if size > sizeof(TestArray) then
- begin
- writeln('Error: File too big');
- halt(1);
- end;
-
- reset(f,1);
- blockread(f,TestPrg^,size,result); {now load the program}
- close(f);
- s := ''; {initialize the work string}
- repeat {simulate a call from the database prg}
- WorkString := 'This is a string from the database simulator'+
- ' '+' '+' '+' '+#0;
- writeln('** Entering BIN program **');
- inline($1E {push ds}
- /$C5/$1E/StrPtr {lds bx,Workstring}
- /$FF/$1E/TestPrg {far call to the BIN prg}
- /$1F); {pop ds}
- writeln('** Returned from BIN program **'); {tell 'em we made it back}
- writeln(WorkString); {show 'em the returned string}
-
- repeat
- write('Run again (Y/N)?'); {ask for a retry}
- readln(s);
- until ((upcase(s[1]) <> 'Y') or (upcase(s[1]) <> 'N')) and
- (length(s) > 0);
- until (upcase(s[1]) = 'N');
- end.